<template>
	<view>
		<u-navbar :border-bottom='false' back-icon-size='48' title="账单"></u-navbar>
		<view class="topBox">
			<view class="title">
				累计佣金
			</view>
			<view class="total">
				{{commission.total_commission}}
			</view>
			<view class="bot-cont">
				<view class="left">
					<text class="num">{{commission.commission}}</text>
					<text class="tit">可提现</text>
				</view>
				<view class="line">

				</view>
				<view class="right">
					<text class="num">{{commission.Withdrawal_amount}}</text>
					<text class="tit">已提现</text>
				</view>
			</view>
		</view>
		<view class="container">
			<view class="bill-li">
				<!-- <view class="totalBox">
					<view class="date">
						<text style="margin-left: 4rpx;">2021年3月</text>
						<u-icon name="arrow-down" color="#333333" size="24"></u-icon>
					</view>
					<view class="num">
						<view class="out">
							支出 ¥1552
						</view>
						<view class="in">
							收入 ¥1552
						</view>
					</view>
				</view> -->
				<view class="detail-ul">
					<view class="detail-li" @click="toDetail(item)" v-for="(item, index) in list" :key="index">
						<image src="../../../../static/imgs/daodianxficon.png" mode=""></image>
						<view class="title">
							<text class="name">{{item.change_msg}}</text>
							<text class="date">{{item.create_time}}</text>
						</view>
						<view class="value">
							+{{item.commission}}
						</view>
					</view>
				</view>
			</view>
		</view>

		<u-picker v-model="showDate" mode="time" start-year='2010' end-year='2021'></u-picker>
	</view>
</template>

<script>
	import request from '@/api/index.js'
	export default {
		data() {
			return {
				showDate: false,
				page: 0,
				hasNext: true,
				user_money: 0,
				list: [],
				commission: {}
			}
		},
		onLoad() {
			this.getData()
			this.getList(true)
		},
		onReachBottom() {
			this.getData()
			this.getList()
		},
		methods: {
			toDetail(item) {
				uni.setStorageSync('bill', item)
				uni.navigateTo({
					url: './billDetail'
				})
			},
			async getList(reload = false) {
				if (reload) {
					this.page = 0
					this.hasNext = true
				}
				if (!this.hasNext) return
				this.page++
				const res = await request.commissionlist({
					page: this.page + '',
					num: 15 + ''
				})
				if (reload) {
					this.list = res.data
				} else {
					this.list.push(...res.data)
				}
				this.user_money = res.user_money
				this.hasNext = res.data.length == 15

			},
			getData() {
				request.mycommission().then(res => {
					this.commission = res.data
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.topBox {
		width: 710rpx;
		height: 316rpx;
		margin: 20rpx auto 0;
		@include bgi('../../../../static/imgs/wodeyjbgj.png');

		.title {
			width: 100%;
			text-align: center;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			padding-top: 48rpx;
		}

		.total {
			width: 100%;
			text-align: center;
			font-size: 44rpx;
			font-family: Arial;
			font-weight: 400;
			color: #FFFFFF;
			margin-top: 6rpx;
		}

		.bot-cont {
			margin-top: 36rpx;
			width: 100%;
			height: 136rpx;
			display: flex;
			align-items: center;
			justify-content: space-around;

			.left,
			.right {
				display: flex;
				align-items: center;
				flex-direction: column;

				.num {
					font-size: 36rpx;
					font-family: Arial;
					font-weight: 400;
					color: #FFFFFF;
				}

				.tit {
					margin-top: 4rpx;
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
				}
			}

			.line {
				width: 0px;
				height: 36rpx;
				border: 2rpx solid #FFFFFF;
				opacity: 0.5;
			}
		}
	}

	.container {
		.bill-li {
			.totalBox {
				width: 100%;
				height: 140rpx;
				background: #F2F2F7;
				padding-left: 42rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;

				.date {
					font-size: 34rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #333333;
				}

				.num {
					display: flex;
					align-items: center;
					margin-top: 4rpx;

					.out,
					.in {
						font-size: 24rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #666666;
					}
				}
			}

			.detail-ul {
				width: 710rpx;
				height: auto;
				background-color: #FFFFFF;
				border-radius: 16rpx;
				margin: 20rpx auto 0;
				padding: 0 20rpx;

				.detail-li {
					&:last-child {
						border-bottom: none
					}

					width: 100%;
					height: 120rpx;
					display: flex;
					align-items: center;
					border-bottom: 2rpx solid #F2F2F7;

					image {
						width: 72rpx;
						height: 72rpx;
					}

					.title {
						display: flex;
						flex-direction: column;
						margin-left: 20rpx;

						.name {
							font-size: 28rpx;
							font-family: Segoe UI;
							font-weight: 400;
							color: #333333;
						}

						.date {
							margin-top: 4rpx;
							font-size: 24rpx;
							font-family: Arial;
							font-weight: 400;
							color: #999999;
						}
					}

					.value {
						margin-left: auto;
						font-size: 32rpx;
						font-family: Arial;
						font-weight: 400;
						color: #333333;
					}
				}
			}
		}
	}
</style>
